package com.ysx.oa.clazz.controller;

import com.ysx.oa.clazz.bean.ClazzBean;
import com.ysx.oa.clazz.service.ClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/clazz")
public class ClazzController{
    @Autowired
    private ClazzService clazzService;

    // http://localhost:8080/kaoqin/clazz/Lww/find?id=800200
    // tomcat被替换了不要用了  所以需要使用ClazzApplication
    @RequestMapping(value = "/Lww/find",method = RequestMethod.GET)
    public Map<String ,Object> findById(Integer id){
        Map<String,Object> map=new HashMap();

        ClazzBean bean=null;
        try{
            bean=clazzService.findById(id);
        }catch (Exception e){
            System.out.println(e);
        }
        map.put("code",200);
        map.put("message","success");
        map.put("data",bean);
        return map;
    }



    @RequestMapping(value = "/Lww/add",method = RequestMethod.POST)
    public Map<String ,Object> add(@RequestBody ClazzBean clazzBean) {
        Map<String, Object> map = new HashMap();
        clazzService.add(clazzBean);

        map.put("code",200);
        map.put("message","success");
        map.put("data",null);
        return map;
    }

}
